package com.clever.mall.mapper;

import com.clever.mall.entity.ShoppingCart;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface ShoppingCartMapper {

    /**
     * 通过用户id查询所有购物车内容
     * @param uid
     * @return
     */
    List<ShoppingCart> selectShoppingCartAll(@Param("uid") int uid);


    /**
     * 分页查询,第一页为 1
     * @param uid
     * @param head
     * @param tail
     * @return
     */
    List<ShoppingCart> selectShoppingCartByLimit(@Param("uid") int uid, @Param("head") int head, @Param("tail") int tail);

    /**
     * 通过用户id和产品id查询购物车数据
     * @param uid
     * @param pid
     * @return
     */
    ShoppingCart selectShoppingCartByUserIdAndProjectId(@Param("uid") int uid, @Param("pid") int pid);

    /**
     * 将商品加入购物车
     * @param shoppingCart
     * @return
     */
    int insertShoppingCart(@Param("sc") ShoppingCart shoppingCart);

    //修改数量
    int updateShoppingCartNumber(@Param("number") int number, @Param("id") int scId);

    /**
     * 通过用户id和产品id删除购物车内容
     * @param uid
     * @param pid
     * @return
     */
    int deleteShoppingCart(@Param("uid") int uid, @Param("pid") int pid);

    /**
     * 批量删除
     * @param shoppingCartList
     * @return
     */
    int deleteShoppingCartList(@Param("scList") List<ShoppingCart> shoppingCartList);


}
